package tests;

import junit.framework.TestCase;
import lz77.util.ByteLinkedList;
import lz77.util.CharLinkedList;
import lz77.util.LinkedListNode;
/**
 * Testaa eri LinkedList -luokat
 * @author ossi
 *
 */
public class LinkedListTest extends TestCase {
	LinkedListNode head;

	protected void setUp() throws Exception {
		super.setUp();
		
	}
	
	public void testCharLinkedList(){
		head = new CharLinkedList('a');
		LinkedListNode node = head;
		
		node.toString(); // coveragea varten, jäi häiritsemään
		
		for (char c = 'b'; c <='z'; c++){
			node.setNext(new CharLinkedList(c));
			node = node.next();
		}
		
		node = head;
		for (char c = 'a'; c <='z'; c++){
			assertEquals(((CharLinkedList)node).value,c);
			node = node.next();
		}
		
	}
	
	public void testByteLinkedList(){
		head = new ByteLinkedList((byte)0);
		LinkedListNode node = head;
		
		node.toString(); // coveragea varten, jäi häiritsemään
		
		for (byte c = 1; c <=100; c++){
			node.setNext(new ByteLinkedList(c));
			node = node.next();
		}
		
		node = head;
		for (byte c = 0; c <=100; c++){
			assertEquals(((ByteLinkedList)node).value,c);
			node = node.next();
		}
		
	}

}
